package com.example.springworkadmin.dao;

import com.example.springworkadmin.entity.ResidentAccount;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository

public interface ResidentAccountDao {

    @Select("select count(*) from household where name like concat('%',#{key},'%')")
    Integer count(@Param("key") String key);

    @Select("select * from household where name like concat('%',#{key},'%') order by account desc limit #{start},#{size}")
    List<ResidentAccount> get(@Param("start")Integer start, @Param("size")Integer limit, @Param("key")String key);

    @Insert("insert into household(account,password,name,phone,id_card,room_number) values(#{o.account},#{o.password},#{o.name},#{o.phone},#{o.idCard},#{o.roomNumber})")
    Integer add(@Param("o")ResidentAccount residentAccount);

    @Update("update household set password=#{o.password},name=#{o.name},phone=#{o.phone},id_card=#{o.idCard},room_number=#{o.roomNumber} where account=#{o.account}")
    Integer update(@Param("o")ResidentAccount residentAccount);

    @Delete("delete from household where account=#{id}")
    Integer delete(@Param("id")String id);

    @Delete("delete from healthy_status where account=#{account}")
    Integer deleteAccess(@Param("account") String account);
}
